class FooterWalker extends Walker_Nav_Menu { private $column_open = false; function start_lvl(&$output, $depth = 0, $args = []) { if ($depth === 0) { $output .= "\n"; } } function start_el(&$output, $item, $depth = 0, $args = [], $id = 0) { // Start new column on top-level items if ($depth === 0) { if ($this->column_open) { $output .= "\n"; // Close previous column } $output .= "
\n"; $output .= "

{$item->title}

\n"; $this->column_open = true; } else { $output .= "
  • url}\">{$item->title}
  • \n"; } } function end_el(&$output, $item, $depth = 0, $args = []) { // Do nothing on end_el } function walk($elements, $max_depth, ...$args) { $output = parent::walk($elements, $max_depth, ...$args); if ($this->column_open) { $output .= "
    \n"; // Close last column $this->column_open = false; } return $output; } }